<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\admin\model\News as NewsModel;

class News extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {

   		//查询新闻，每页显示6条
    	$list = NewsModel::where('status',1)->paginate(6);
    	// 获取分页显示
    	$page = $list->render();
    	$this->assign('list',$list);
    	$this->assign('page',$page);
    	return $this->view->fetch();
    }

    public function info()
    {
    	$id = input('id',0,'intval');
    	//$id = input('post.id',0,'intval');
    	//$id = $this->request->get('id',0,'intval');
    	//$id = $this->request->post('id',0,'intval');
    	//$id = $this->request->param('id',0,'intval');
    	if(empty($id)){
    		$this->error('参数id不能为空');
    	}
    	$pageinfo = NewsModel::where('status',1)->where('id',$id)->find();
    	if(empty($pageinfo)){
    		$this->error('没有数据');
    	}
    	$this->assign('info',$pageinfo);
    	return $this->view->fetch();
    }
}
